package seqlist.oj;

/**
 * 判断链表是否带环
 */
public class Num141 {
    public boolean hasCycle(ListNode head) {
        ListNode low = head,fast = head;
        while (fast != null && fast.next != null) {
            low = low.next;
            fast = fast.next.next;
            if (low == fast) {
                // 此时相遇了
                return true;
            }
        }
        return false;
    }
}
